package 超市购物系统;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    private static List<Goods> list = new ArrayList<>();

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("    欢迎使用超市购物系统      ");
        list.add(new Goods("001", "少林核桃", 15.5, "斤"));
        list.add(new Goods("002", "尚康饼干", 14.5, "包"));
        list.add(new Goods("003", "移动硬盘", 345.0, "个"));
        list.add(new Goods("004", "高清无码", 199.0, "G"));
        demo();
    }

    public static void demo() {
        GoodsMethod goodsMethod = new GoodsMethod(list);
        while(true) {
            int num = oper();
            ifOpera(num, goodsMethod);
        }
    }


    public static int oper() {
        System.out.println("请输入你要进行的操作：");
        System.out.println("1:购买商品     `2:结算并打印小票      3;退出系统");
        int i = sc.nextInt();
        return i;
    }



    public static void ifOpera(int num, GoodsMethod goodsMethod) {
        switch (num) {
            case 1:
                goodsMethod.buyGoods();
                break;
            case 2:
                goodsMethod.jieSuan();
                break;
            case 3:
                System.out.println("感谢您使用超市购物系统，欢迎下次光临，拜拜");
                System.exit(0);
                break;
            default:
                System.out.println("您的输入有误");
                break;
        }
    }
}
